package com.cskaoyan.market.service.impl;

import com.cskaoyan.market.db.domain.MarketLog;
import com.cskaoyan.market.db.domain.MarketLogExample;
import com.cskaoyan.market.db.mapper.MarketLogMapper;
import com.cskaoyan.market.service.AdminLogeService;
import com.cskaoyan.market.util.MybatisUtils;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.Calendar;
import java.util.List;

/**
 * @author:yanzijun
 * @time:2024/06/21/9:13
 */
public class AdminLogServiceImpl implements AdminLogeService {
    @Override
    public List<MarketLog> list(String page, String limit, String name, String sort, String order) {
        SqlSession session = MybatisUtils.getSession();
        MarketLogMapper mapper = session.getMapper(MarketLogMapper.class);
        MarketLogExample marketLogExample = new MarketLogExample();
        MarketLogExample.Criteria criteria = marketLogExample.createCriteria();
        if (StringUtils.isNotEmpty(name)) {
            criteria.andAdminLike("%" + name + "%");
        }
        marketLogExample.setOrderByClause(sort + " " + order);
        PageHelper.startPage(Integer.parseInt(page), Integer.parseInt(limit));
        List<MarketLog> marketLogs = mapper.selectByExample(marketLogExample);
        session.close();
        return marketLogs;
    }
}
